#pragma once

#include <Guiddef.h>
#include <MAPI.h>
#include <MAPIDefS.h>
#include <MAPICode.h>

class IObjectCollection;
class ISession;

// {D950FE7B-EA12-49f2-8E54-75856881E27E}
DEFINE_GUID(IID_IProtocol,
0xd950fe7b, 0xea12, 0x49f2, 0x8e, 0x54, 0x75, 0x85, 0x68, 0x81, 0xe2, 0x7e);

class IProtocol: public IUnknown
{
public:
	virtual STDMETHODIMP CreateSession(ISession ** lppNewSession) = 0;
};



// {FB3FBED5-4834-4ca7-98FC-59713E85099C}
DEFINE_GUID(IID_ISession,
0xfb3fbed5, 0x4834, 0x4ca7, 0x98, 0xfc, 0x59, 0x71, 0x3e, 0x85, 0x9, 0x9c);

class ISession: public IUnknown
{
public:
	virtual STDMETHODIMP Logon(
		LPCTSTR				lpszServerURI,
		LPCTSTR				lpszUser,
		LPCTSTR				lpszPassword,
		ULONG				ulFlags) = 0;

	virtual STDMETHODIMP GetCollection(
		LPCTSTR				lpszCollectionURI,
		ULONG				ulFlags,
		IObjectCollection** lppObjectCollection) = 0;

	virtual STDMETHODIMP Logoff() = 0;
};

class IObject;


// {849563F5-E659-4010-9536-A50EF14E55B4}
DEFINE_GUID(IID_IObjectCollection, 
0x849563f5, 0xe659, 0x4010, 0x95, 0x36, 0xa5, 0xe, 0xf1, 0x4e, 0x55, 0xb4);

class IObjectCollection: public IUnknown
{
public:
	
	virtual STDMETHODIMP Find(
		ULONG ulFlags,
		const FILETIME *	lpftStart,
		const FILETIME *	lpftEnd,
		ULONG *				lpulCount) = 0;

	virtual STDMETHODIMP GetID(
		ULONG		ulIndex,
		LPSBinary	lpID) = 0;

	virtual STDMETHODIMP Get(
		ULONG		ulIndex,
		IObject	**	lppObject) = 0;

	virtual STDMETHODIMP Add(
		IObject	**	lppNewObject) = 0;

};


// {2DC9B7AA-2578-4a83-9D8B-11A5931D2296}
DEFINE_GUID(IID_IObject,
0x2dc9b7aa, 0x2578, 0x4a83, 0x9d, 0x8b, 0x11, 0xa5, 0x93, 0x1d, 0x22, 0x96);

class IObject: public IUnknown
{
public:
	virtual STDMETHODIMP Export(
		ULONG ulFlags,
		IMessage* lpTargetMessage) = 0;

	virtual STDMETHODIMP Import(
		ULONG		ulFlags,
		IMessage* lpSourceMessage) = 0;
};


STDMETHODIMP RegisterProtocol(LPGUID lpProtocolID, IProtocol* lpNewProtocol);

STDMETHODIMP GetSession(LPGUID lpProtocolID, ISession ** lppSesion);